#from iptcinfo import IPTCInfo
import commands
import types
import os
import re
import pdb
import pickle
import fdict
from collections import defaultdict

class Stats:
    def __init__(self,fd=None):
        if fd is None:
            self.fdict = fdict.FDict("./src/4chan/b/fdict.p")
        else:
            self.fdict = fd
        self.kwdict = self.fdict.kwdict
        
    def basics(self,num=10):
        self.tagl = self.kwdict.keys()
        self.tagn = len(self.tagl)
        self.popu = []
        self.untgd = self.kwdict["new"].__len__()
        self.ttlimgs  = self.fdict.__len__()
        for tag in self.tagl:
            tup = (tag, self.kwdict[tag].__len__())
            self.popu.append(tup)
        popu = self.popu
        self.popu.sort(key=lambda popu: popu[1])
        self.popu.reverse()
        return self
